﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class TicketTypeBLO
    {
        private TicketTypeDAO _ticketTypeDAO = new TicketTypeDAO();

        /// <summary>
        /// List all ticket types in LoadTicketTypes at TicketTypeDAO
        /// </summary>
        /// <returns>ticket type list</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public List<TicketType> LoadAllTicketTypes()
        {
            var ticketTypeList = _ticketTypeDAO.LoadTicketTypes();
            return ticketTypeList;
        }

        /// <summary>
        /// Load Ticket Type by Id 
        /// </summary>
        /// <param name="ticketTypeId"></param>
        /// <returns>A current ticket type</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public TicketType LoadATicketType(int ticketTypeId)
        {
            var curTicketType = _ticketTypeDAO.SelectTicketType(ticketTypeId);
            return curTicketType;
        }

        /// <summary>
        /// Check if Ticket type name is existed or not
        /// </summary>
        /// <param name="ticketType"></param>
        /// <returns>true || false</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public bool CheckIsExisted(TicketType ticketType)
        {
            return _ticketTypeDAO.CheckIsExisted(ticketType);
        }

        /// <summary>
        /// Create a new ticket type
        /// </summary>
        /// <param name="ticketType"></param>
        /// <returns>true || false</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public bool AddTicketType(TicketType ticketType)
        {
            var isSuccess = _ticketTypeDAO.CreateTicketType(ticketType);
            if (isSuccess == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Update a ticket type
        /// </summary>
        /// <param name="ticketType"></param>
        /// <returns>true || false</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public bool UpdateTicketType(TicketType ticketType)
        {
            var isSuccess = _ticketTypeDAO.EditTicketType(ticketType);
            if (isSuccess == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Delete a ticket type
        /// </summary>
        /// <param name="ticketType"></param>
        /// <returns> true || false</returns>
        /// <author>duyhdv</author>
        /// <date>2014/03/3</date>
        public bool DeleteTicketType(TicketType ticketType)
        {
            var isSuccess = _ticketTypeDAO.RemoveTicketType(ticketType);
            //if Delete in TicketTypeDAO sucessfull
            if (isSuccess == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}